package cn.craftyun.yunexam.service.impl;

import cn.craftyun.yunexam.entity.AdminUser;
import cn.craftyun.yunexam.mapper.AdminUserMapper;
import cn.craftyun.yunexam.service.AdminUserService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser> implements AdminUserService {
    /**
     * 通过用户名获取用户
     *
     * @param username 用户名
     * @return 用户对象
     */
    @Override
    public AdminUser findByUsername(String username) {
        // 用户登录
        Wrapper<AdminUser> wrapper = new QueryWrapper<AdminUser>()
                .eq("username", username)
                .last("limit 1");
        return getBaseMapper().selectOne(wrapper);
    }
}
